// 微信小程序所有API promise化，支持await、支持请求列队 https://github.com/bigmeow/minapp-api-promise
import wxp from 'minapp-api-promise'
// moment.js https://github.com/moment/moment
import moment from 'moment'
// qrcode生成 https://github.com/alsey/wxbarcode
import wxbarcode from 'wxbarcode'
// 工具函数
import * as money from './money'
import * as animation from './animation'
import * as random from './random'
import * as conSole from './console'

const plugin = [
  {
    label: '$wxp',
    value: wxp
  },
  {
    label: '$moment',
    value: moment
  },
  {
    label: '$wxbarcode',
    value: wxbarcode
  },
  {
    label: '$money',
    value: money
  },
  {
    label: '$animation',
    value: animation
  },
  {
    label: '$random',
    value: random
  },
  {
    label: '$console',
    value: conSole
  }
]

const install = Vue => {
  if (install.installed) return
  plugin.map(element => {
    Object.defineProperty(Vue.prototype, element.label, {
      value: element.value
    })
  })
}

export default {
  install
}
